package com.example.javabase.multithread.unreentrantlock;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author He Changjie on 2021/7/10
 */
public class UnReentrantLockMain {
    public static void main(String[] args) {
        // 可重入锁
        Lock lock = new ReentrantLock();
        // 不可重入锁
//        Lock lock = new UnReentrantLock();
        lock.lock();
        try {
            System.out.println("第一次获取锁");
            lock.lock();
            try {
                System.out.println("第二次获取锁");
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                lock.unlock();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }
    }
}
